import PubSub from 'PubSub'

class EventBus {
    constructor() {
        this.pubSub = new PubSub()
    }

    register(eventName, callback) {
        return this.pubSub.subscribe(eventName, callback)
    }

    unregister(token) {
        this.pubSub.unsubscribe(token)
    }

    post(eventName, data) {
        this.pubSub.publish(eventName, data)
    }
}

const eventBus = new EventBus()
export default eventBus;
